package jgl.vajra.driver.part.vehicle.activity;

import androidx.recyclerview.widget.LinearLayoutManager;

import java.util.ArrayList;
import java.util.List;

import jgl.vajra.driver.R;
import jgl.vajra.driver.databinding.ActivityDriverCollectionBinding;
import jgl.vajra.driver.databinding.ItemDriverCollectionBinding;
import jgl.vajra.driver.part.vehicle.viewModel.DriverCollectionViewModel;
import jgl.vajra.driver.widget.databindingadapter.BaseDataBindingDecorator;
import jgl.vajra.driver.widget.databindingadapter.SingleTypeBindingAdapter;
import jgl.vajra.driver.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.driver.widget.mvvm.view.BaseMVVMActivity;

@CreateViewModel(DriverCollectionViewModel.class)
public class DriverCollectionActivity extends BaseMVVMActivity<DriverCollectionViewModel, ActivityDriverCollectionBinding> {
    @Override
    public int getLayoutId() {
        return R.layout.activity_driver_collection;
    }

    @Override
    public void initView() {
        super.initView();
        mBinding.toolbar.setNavigationIcon(R.drawable.ic_left_arrow);
        mBinding.toolbar.setNavigationOnClickListener(view -> finish());

        List<String> list=new ArrayList<>();
        list.add("5年工作经验");
        list.add("专属服务2次");

        // 不可嵌套滑动
        mBinding.recyclerView.setNestedScrollingEnabled(false);
        // 取消head 的 recycleView的焦点
        mBinding.recyclerView.setFocusableInTouchMode(false);
        //设置布局管理器
        mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
        SingleTypeBindingAdapter adapter = new SingleTypeBindingAdapter(this, list, R.layout.item_driver_collection);
        mBinding.recyclerView.setAdapter(adapter);
        adapter.setItemDecorator((BaseDataBindingDecorator<String, ItemDriverCollectionBinding>) (binding, position, viewType, data) -> {

            // 不可嵌套滑动
            binding.itemRecyclerView.setNestedScrollingEnabled(false);
            // 取消head 的 recycleView的焦点
            binding.itemRecyclerView.setFocusableInTouchMode(false);
            //设置布局管理器
            binding.itemRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
            SingleTypeBindingAdapter itemAdapter = new SingleTypeBindingAdapter(this, list, R.layout.item_driver_collection_item);
            binding.itemRecyclerView.setAdapter(itemAdapter);

        });
    }

}
